<template>
	<view class="Details">
		<app-title :title='`${title}明细`'></app-title>
		<view class="Details_">
			<view class="Details_yue">
				<view class="Details_yue_title">
					<p>当前{{title}}</p>
					<h2>{{res.total}}</h2>
				</view>
				<view class="Details_yue_right">
					<p v-if="title === '抖推币'"
						@click="toFun('/pages/member/interconversion/interconversion?title=抖推币&type=mjf')">
						互&nbsp;&nbsp;&nbsp;转</p>
					<!-- <p v-if="title === '绿色积分'" @click="inputDialogToggle">一键复投</p> -->
				</view>
			</view>
			<uv-divider class="Details_fenge" :text="`${title}明细`" textColor="#ff0000" lineColor="#ccc"></uv-divider>


			<view class="Details_box">
				<scroll-view :scroll-top="0" scroll-y="true" class="Details_box_scroll" @scrolltolower="lower">
					<view class="app_list_center_scroll_item" v-for="(item,index) in list" :key=" index">
						<view class="app_list_center_scroll_item_" style="text-align: left;">
							<view class="app_list_center_scroll_item_remark">
								{{item.remark }}
							</view>
							<view class="app_list_center_scroll_item_createtime">
								{{item.createtime?item.createtime:item.time}}
							</view>
						</view>
						<view class="app_list_center_scroll_item_" style="color: #d50a05;text-align: right;">
							{{item.num}}
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
		<!-- <uni-popup ref="inputDialog" type="dialog">
			<uni-popup-dialog ref="inputClose" mode="base" type="warning" title="一键复投" @close="dialogClose"
				@confirm="dialogInputConfirm">
				<slot>
					<p style="color: red;font-size: 24rpx;margin:0 0 20rpx 0;">复投须为1的倍数</p>
					<uni-easyinput :value="num" type="number" placeholder="请输入复投数量" @input="numfun" />
				</slot>
			</uni-popup-dialog>
		</uni-popup> -->



		<!-- <view class="pay_password">
			<u-keyboard mode="number" @change="valChange" @backspace="backspace" :dotDisabled="true"
				@cancel="show = !show,paypwd = ''" @confirm="api_index_m_ftFun()" :show="show">
				<slot name="default">
					<p style="padding: 20rpx;text-align: center;">请输入交易密码</p>
					<u-code-input v-model="paypwd" :disabledKeyboard='true' mode="line"
						style="padding: 20rpx;"></u-code-input>
				</slot>
			</u-keyboard>
		</view> -->
	</view>
</template>

<script>
	import {
		api_index_get_detail_list,
		api_index_m_ft
	} from '@/api/member.js'
	export default {
		data() {
			return {
				equipment: '',
				type: '',
				res: '',
				title: '',
				page: 1,
				openid: '',
				list: [],
				num: '',
				show: false,
				paypwd: ''
			};
		},
		onLoad(e) {
			console.log(e.type);
			this.type = e.type;
			this.title = e.title;

			uni.setNavigationBarTitle({
				title: this.title
			});
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data;
					this.api_index_get_detail_listFun();
				}
			});
			if (process.env.UNI_PLATFORM === 'h5') {
				// 在H5环境中打开
				console.log('在H5环境中打开');
				this.equipment = 'H5'
			} else if (process.env.UNI_PLATFORM === 'app-plus') {
				// 在App环境中打开
				console.log('在App环境中打开');
				this.equipment = 'App'
			}
		},
		methods: {
			async api_index_m_ftFun() {
				let up = {
					openid: this.openid,
					num: this.num,
					paypwd: this.paypwd
				}
				let data = await api_index_m_ft(up);
				this.$refs.inputDialog.close();
				this.num = '';
				this.paypwd = '';
				this.show = false;
				if (data.error === 0) {
					setTimeout(() => {
						this.page = 1;
						this.api_index_get_detail_listFun();
					}, 1000)
				}
			},
			valChange(e) {
				console.log(e);
				if (this.paypwd.length > 6) {
					return
				} else {
					this.paypwd += e;
				}
			},
			backspace(e) {
				if (this.paypwd.length) this.paypwd = this.paypwd.substr(0, this.paypwd.length - 1);
			},
			numfun(e) {
				if (e.indexOf('.') !== -1) {
					let i = e.indexOf('.');
					let arr = e.split('');
					arr.splice(i, 1);
					this.num = arr.join('');
					console.log(this.num);
				} else {
					this.num = e;
				}
			},
			inputDialogToggle() {
				this.$refs.inputDialog.open()
			},
			dialogClose() {
				console.log('点击关闭')
			},
			dialogInputConfirm() {
				console.log('1111111');
				if (this.num !== '') {
					this.show = !this.show
				}
			},
			toFun(url) {
				uni.navigateTo({
					url
				})
			},
			lower() {
				this.page++;
				this.api_index_get_detail_listFun()
			},
			//提示
			showinteraction(title, icon = 'none') {
				uni.showToast({
					title,
					icon,
					duration: 2000,
					mask: false
				})
			},
			async api_index_get_detail_listFun() {
				let up = {
					openid: this.openid,
					page: this.page,
					type: this.type
				}
				let data = await api_index_get_detail_list(up);
				this.res = data;
				if (data.error === 0) {
					data.list.forEach(item => {
						this.list.push(item)
					})
				} else {
					this.showinteraction('到底了~')
				}
			},

		}
	}
</script>

<style lang="scss">
	.Details {
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;

		.Details_ {
			width: 100%;
			flex: 1;
			padding: 0 40rpx;
			display: flex;
			flex-direction: column;
			overflow: hidden;
		}

		.Details_yue {
			width: 100%;
			height: 220rpx;
			background-image: url('@/static/member/hldt.png');
			background-repeat: no-repeat;
			background-size: 100%;
			padding: 20rpx 40rpx;
			color: #fff;
			margin: 10rpx 0;
			display: flex;
			justify-content: space-between;



			.Details_yue_title {
				height: 130rpx;
				color: #fff;
				font-size: 26rpx;
				line-height: 40rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				h2 {
					font-size: 60rpx;
				}

			}

			.Details_yue_right {
				height: 160rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				p {
					height: 40rpx;
					padding: 0rpx 20rpx;
					background-color: #fff;
					color: #333;
					border-radius: 100rpx;
					font-size: 28rpx;
					line-height: 40rpx;
					text-align: center;

				}
			}

		}

		.Details_fenge {
			height: 80rpx;
			margin: 0;
		}

		.Details_box {
			width: 100%;
			flex: 1;
			padding: 10rpx;
			overflow: auto;

			.Details_box_scroll {
				width: 100%;
				height: 100%;

				.app_list_center_scroll_item {
					width: 100%;
					margin: 20rpx 0;
					display: flex;
					text-align: center;
					justify-content: space-around;
					align-items: center;
					line-height: 40rpx;

					.app_list_center_scroll_item_ {
						font-size: 26rpx;
						flex: 1;
					}
				}

			}


		}


	}
</style>